# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

_http_error_code_to_error_message = {
    '200':
        "Request was successful",
    '30x':
        "API entry point has moved, see Location: header. Most likely an http: to https: redirect.",
    '400':
        "The request was malformed; in the case of a private API request, missing or malformed Gemini private API authentication headers",
    '403':
        "The API key is missing the role necessary to access this private API endpoint",
    '404':
        "Unknown API entry point",
    '429':
        "Rate Limiting was applied",
    '500':
        "The server encountered an error",
    '502':
        "Technical issues are preventing the request from being satisfied",
    '503':
        "The exchange is down for maintenance",
}


def gemini_strerror(http_status_code: int) -> str:
  status_code_str = str(http_status_code)
  if status_code_str.startswith('30'):
    return _http_error_code_to_error_message['30x']
  elif status_code_str in _http_error_code_to_error_message:
    return _http_error_code_to_error_message[status_code_str]
  else:
    return 'Unknown http status code!'
